/**
 * @author yxw
 * date : 2013年10月1日 上午12:08:53 
 * 此类用于二手房，新房，租房的的基础activity
 */
package com.tzinfo.tzt.activity;

import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;

import com.tzinfo.tzt.R;
import com.tzinfo.tzt.activity.util.MyApplication;
import com.tzinfo.tzt.config.FilterConfig;

public class ListBaseActivity extends BaseActivity implements OnScrollListener{

	protected String atcivity_flag = "new_house";
	protected Button bt_local;
	protected RadioButton rbt_top_bt1, rbt_top_bt2, rbt_top_bt3;
	protected EditText et_search_top;
	protected TextView un_locationCode;
	protected Resources resources;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main_list);
		initBase();
	}

	protected void initBase() {
		resources = getBaseContext().getResources();
		un_locationCode=(TextView) this.findViewById(R.id.un_locationCode);
		un_locationCode.setText(MyApplication.locationCode+"");
		bt_local = (Button) this.findViewById(R.id.bt_local);
		rbt_top_bt1 = (RadioButton) this.findViewById(R.id.radio_top_btn1);
		rbt_top_bt2 = (RadioButton) this.findViewById(R.id.radio_top_btn2);
		rbt_top_bt3 = (RadioButton) this.findViewById(R.id.radio_top_btn3);
		et_search_top = (EditText) this.findViewById(R.id.et_search_top);
		if(MyApplication.locationCode==-1){
			String sLocationCode=sharedPreferences.readMessage("locationCode");
			if(sLocationCode==null||"".equals(sLocationCode)){
				Intent intent=new Intent(this, SelectCityActivity.class);
				startActivityForResult(intent, 1);
			}else{
				MyApplication.locationCode=Integer.parseInt(sLocationCode);
				String s=FilterConfig.FILTER_CONTENT[0][MyApplication.locationCode];
				bt_local.setText(s);
			}
		}else{
			String s=FilterConfig.FILTER_CONTENT[0][MyApplication.locationCode];
			bt_local.setText(s);
		}
		
	}
	protected void showLastRow(){
		Toast.makeText(ListBaseActivity.this, "已经是最后一页！", 5000).show();
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);
		if(requestCode==1){
			if(resultCode==2){
				String s=FilterConfig.FILTER_CONTENT[0][MyApplication.locationCode];
				if(MyApplication.locationCode!=0){
					s=s.substring(0, s.length()-1);
				}
				bt_local.setText(s);
			}
		}
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub
		return super.onTouchEvent(event);
	}

	@Override
	public void onScroll(AbsListView view, int firstVisibleItem,
			int visibleItemCount, int totalItemCount) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onScrollStateChanged(AbsListView view, int scrollState) {
		// TODO Auto-generated method stub
		
	}

}
